import BetterScroll from 'better-scroll'

let bs = null

export default {
  bind: function(el) {
    bs = new BetterScroll(el, {
      probeType: 3,
      click: true,
      listenScroll: true
    })
  },
  update: function() {
    if (bs) {
      bs.refresh()
    }
  },
  componentUpdated: function() {
    if (bs) {
      bs.refresh()
    }
  },
  inserted: function(el) {
    bs = new BetterScroll(el, {
      probeType: 3,
      click: true,
      listenScroll: true
    })
  },
  unbind: function() {
    bs.destroy()
  }
}
